enum SocketState {
    NotJoined = 0,  // 0: 未加入
    Joined = 1,     // 1: 已加入
    Left = 2,       // 2: 已离开
    RoomFull = 3    // 3: 房间已满
}

interface ClientInfo {
    clientId: string;
    username: string;
}

class Room {
    private users: Map<string, ClientInfo> = new Map();
    private maxUsers: number;

    constructor(maxUsers: number = 1000) {
        this.maxUsers = maxUsers;
    }

    addUser(socketId: string, username: string): boolean {
        if (this.users.size < this.maxUsers) {
            this.users.set(socketId, {clientId: socketId, username});
            return true;
        }
        return false;
    }

    removeUser(socketId: string) {
        this.users.delete(socketId);
    }

    getRoomInfo() {
        return {
            size: this.users.size,
            clients: Array.from(this.users.values()),
        };
    }
}

export default Room;